import QtQuick 1.0
//import ShellInvoker 1.0
import "../../../common/lib/kdeadmouseutils-build-desktop"

Item {
    id: listItem
    signal select(string id)
    
    width: 500
    height: 600
    anchors.centerIn: parent
    ListModel {
	  id : plModel
    }
    
    QmlSetting{
      id:setting
      appName:'pluzz'
    }
    
    Rectangle {
	  id:rectHome
	  color: "#3E606F"
	  anchors.fill: parent
	  anchors.centerIn: parent
	  ListView {
		  width: parent.width - 40
		  height: parent.height - 40
		  anchors.centerIn: parent
		  focus: true
		  model:plModel
		  orientation : ListView.Vertical
		  spacing : 25
		  delegate: Rectangle {
				  id:rectItem
				  color: "#91AA9D"
				  smooth: true
				  //clip:false
				  radius: 10
				  anchors.horizontalCenter:parent.horizontalCenter
				  width: ListView.view.width - 100
				  height: 60
				  Text {
				      anchors.centerIn: rectItem
				      text: label
				      color: "#193441"
				      font.pixelSize: 30
				    }
				   states: State {
					name: "active"; when: rectItem.activeFocus
					PropertyChanges { target: rectItem;scale: 1.3 }
					//PropertyChanges { target: label; font.pixelSize: 16 }
				    }

				    transitions: Transition {
					NumberAnimation { properties: "scale"; duration: 100 }
				    }
				    
				    Keys.onReturnPressed : {
					listItem.select(url);
					event.accepted = true;
				    }
				    
				}
	      }
    }
    
    Component.onCompleted: {
	var l = setting.getListKeys('podcastList');
	setting.beginGroup('podcastList');
	for(var i = 0;i<l.length;i++){
	  console.log('item:' + l[i]);
	  plModel.append({
	       "name": l[i]
	      ,"label": setting.value(l[i]+'/label')
	      ,"url": setting.value(l[i]+'/url')
	  })
	}
	setting.endGroup();
	//improuve this
    }
      
       
   
        
}
